package com.cloudbroker.openapi.mobile.controller;

import static com.cloudbroker.bcs.platform.dav.common.util.RequestUtil.getSingleParameterMapForBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import com.cloudbroker.bcs.platform.dav.bizapi.constants.status.ChatMsgType;
import com.cloudbroker.bcs.platform.dav.bizapi.service.chat.result.*;
import com.cloudbroker.bcs.platform.dav.bizapi.service.viewpoint.vo.ChatTopicListQryForm;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cloudbroker.bcs.common.entity.HSBCPSBackVO;
import com.cloudbroker.bcs.common.util.VOUtil;
import com.cloudbroker.bcs.platform.dav.bizapi.service.base.vo.HSBCPSVO;
import com.cloudbroker.bcs.platform.dav.bizapi.service.chat.vo.BrokerInfoBackForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.chat.vo.BrokerInfoNologinBackForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.chat.vo.BrokerInfoNologinForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.chat.vo.ChatHisBackForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.chat.vo.GetCacheChatMsgForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.chat.vo.GetHisChatMsgForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.chat.vo.LiveBroadcastUrlForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.chat.vo.RollingMsgListForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.chat.vo.SetHisChatForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.chat.vo.TenantKeyForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.viewpoint.vo.BrokerIdListQryForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.viewpoint.vo.TenantKeyListQryForm;
import com.cloudbroker.bcs.platform.dav.bizapi.t2service.chat.ChatT2BizService;
import com.cloudbroker.bcs.platform.dav.bizapi.t2service.chat.LiveInvestBizService;
import com.cloudbroker.bcs.platform.dav.bizapi.t2service.chat.RollingT2BizService;
import com.cloudbroker.bcs.platform.dav.bizapi.t2service.viewpoint.BrokerT2BizService;
import com.cloudbroker.bcs.platform.dav.common.ext.annotation.SaveLog;

@Controller
public class ChatController {
    
    @Resource
    private ChatT2BizService chatT2;
    
    @Resource
    private RollingT2BizService rollingT2;
    
    @Resource
    private LiveInvestBizService liveT2;
    
    @Resource
    private BrokerT2BizService brokerT2;
    
    /**
     * 滚动消息获取
     * */
    @ResponseBody
    @RequestMapping("/func_rolling_msg_list_get")
    @SaveLog(remark = "滚动消息获取")
    public RollingMsgListResult funcRollingMsgListGet(HttpServletRequest request, String jsonpcallback) {
        RollingMsgListForm form = getSingleParameterMapForBody(request, RollingMsgListForm.class);
        return VOUtil.setJsonpResult(rollingT2.funcRollingMsgListGet(form), jsonpcallback);
    }
    
    /**
     * 获取大V个人信息
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_broker_info_qry")
    @SaveLog(remark = "获取大V个人信息")
    public BrokerInfoBackForm queryBrokerInfo(HttpServletRequest request, String jsonpcallback) {
        HSBCPSVO form = getSingleParameterMapForBody(request, HSBCPSVO.class);
        return VOUtil.setJsonpResult(chatT2.queryBrokerInfo(form), jsonpcallback);
    }
    
    /**
     * 获取大V个人信息（未登录获取昵称）
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_broker_info_qry_nologin")
    @SaveLog(remark = "获取大V个人信息（未登录获取昵称）")
    public BrokerInfoNologinBackForm queryBrokerInfoNologin(HttpServletRequest request, String jsonpcallback) {
        BrokerInfoNologinForm form = getSingleParameterMapForBody(request, BrokerInfoNologinForm.class);
        return VOUtil.setJsonpResult(chatT2.queryBrokerInfoNologin(form), jsonpcallback);
    }
    
    /**
     * 获取聊天历史记录
     * */
    @ResponseBody
    @RequestMapping("/func_get_his_chat")
    @SaveLog(remark = "获取聊天历史记录")
    public ChatHisBackForm funcGetHisChat(HttpServletRequest request, String jsonpcallback) {
        GetCacheChatMsgForm form = getSingleParameterMapForBody(request, GetCacheChatMsgForm.class);
        return VOUtil.setJsonpResult(chatT2.funcGetHisChat(form), jsonpcallback);
    }
    
    /**
     * 记录聊天信息
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_set_his_chat")
    @SaveLog(remark = "记录聊天信息")
    public HSBCPSBackVO funcSetHisChat(HttpServletRequest request, String jsonpcallback) {
        SetHisChatForm form = getSingleParameterMapForBody(request, SetHisChatForm.class);
        form.setMsg_type(ChatMsgType.FANS.getVal());
        return VOUtil.setJsonpResult(chatT2.funcSetHisChat(form), jsonpcallback);
    }
    
    /**
     * 聊天室视频直播获取
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_live_broadcast_url_get")
    @SaveLog(remark = "聊天室视频直播获取")
    public LiveBroadcastUrlDetailResult funcLiveBroadcastUrlGet(HttpServletRequest request, String jsonpcallback) {
        HSBCPSVO form = getSingleParameterMapForBody(request, LiveBroadcastUrlForm.class);
        return VOUtil.setJsonpResult(chatT2.funcLiveBroadcastUrlGet(form), jsonpcallback);
    }
    
    /**
     * 获取直播列表
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_live_invest_List")
    @SaveLog(remark = "获取直播列表")
    public LiveInvestListResult funcLiveInvestList(HttpServletRequest request, String jsonpcallback) {
        TenantKeyListQryForm form = getSingleParameterMapForBody(request, TenantKeyListQryForm.class);
        return VOUtil.setJsonpResult(liveT2.liveInvestList(form), jsonpcallback);
    }
    
    /**
     * 历史直播列表
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_history_live_invest_list")
    @SaveLog(remark = "历史直播列表")
    public HistoryInvestList funcHistoryLiveInvestList(HttpServletRequest request, String jsonpcallback) {
        BrokerIdListQryForm form = getSingleParameterMapForBody(request, BrokerIdListQryForm.class);
        return VOUtil.setJsonpResult(liveT2.historyLiveInvestList(form), jsonpcallback);
    }
    
    /**
     * 券商投顾列表
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_company_broker_list")
    @SaveLog(remark = "券商投顾列表")
    public CompanyBrokerList funcCompanyBrokerList(HttpServletRequest request, String jsonpcallback) {
        TenantKeyListQryForm form = getSingleParameterMapForBody(request, TenantKeyListQryForm.class);
        return VOUtil.setJsonpResult(liveT2.funcCompanyBrokerList(form), jsonpcallback);
    }
    
    /**
     * 获取数据库聊天历史记录
     * */
    @ResponseBody
    @RequestMapping("/func_preview_his_chat")
    @SaveLog(remark = "获取数据库聊天历史记录")
    public ChatMsgPageResult funcPreviewHisChat(HttpServletRequest request, String jsonpcallback) {
        GetHisChatMsgForm form = getSingleParameterMapForBody(request, GetHisChatMsgForm.class);
        return VOUtil.setJsonpResult(chatT2.funcPreviewHisChat(form), jsonpcallback);
    }
    
    /**
     * 获取多投顾基础信息
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_tenant_info_get")
    @SaveLog(remark = "获取多投顾基础信息")
    public TenantInfoResult funcTenantInfoGet(HttpServletRequest request, String jsonpcallback) {
        TenantKeyForm form = getSingleParameterMapForBody(request, TenantKeyForm.class);
        return VOUtil.setJsonpResult(chatT2.funcTenantInfoGet(form), jsonpcallback);
    }

    /**
     * 直播话题列表
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_chattopic_list")
    @SaveLog(remark = "直播话题列表")
    public ChattopicQueryList funcChattopicList(HttpServletRequest request, String jsonpcallback) {
        ChatTopicListQryForm form = getSingleParameterMapForBody(request, ChatTopicListQryForm.class);
        return VOUtil.setJsonpResult(liveT2.funcChattopicList(form), jsonpcallback);
    }
}
